// -----------------------------
// Author: 		Dhaenens Gert 
// Creation: 	9/17/2014 9:52:19 AM				
// -----------------------------

#ifndef _LuaStaticDataMember_h
#define _LuaStaticDataMember_h

#include "ObjectLuaCommon.h"
#include "Lua.h"

namespace ObjectLua
{

	template<typename Class>
	class LuaStaticDataList;

	template<typename Class>
	class BaseLuaStaticDataMember
	{
	public:
		friend class LuaStaticDataList<Class>;

		virtual void	setValue(Lua* lpLua, int idx) = 0;
		virtual void	getValue(Lua* lpLua) = 0;

		bool			isReadOnly() const;

	protected:
		BaseLuaStaticDataMember(const char* name, bool bReadOnly);
		virtual ~BaseLuaStaticDataMember();

		char*						m_lpName;
		bool						m_bReadOnly;
		BaseLuaStaticDataMember<Class>*	m_lpNext;

	private:
		BaseLuaStaticDataMember(const BaseLuaStaticDataMember& refBaseLuaStaticDataMember);
		BaseLuaStaticDataMember& operator=(const BaseLuaStaticDataMember& refBaseLuaStaticDataMember);
	};

	/* Static Data Member */
	template<typename Class, typename T>
	class LuaStaticDataMember : public BaseLuaStaticDataMember<Class>
	{
	public:
		typedef T*	DataMember;

		LuaStaticDataMember(const char* name, DataMember member, bool bReadOnly);
		virtual ~LuaStaticDataMember();

		virtual void	setValue(Lua* lpLua, int idx);
		virtual void	getValue(Lua* lpLua);

	private:

		DataMember		m_Member;

		LuaStaticDataMember(const LuaStaticDataMember& refLuaStaticDataMember);
		LuaStaticDataMember& operator=(const LuaStaticDataMember& refLuaStaticDataMember);
	};

	/* Const Static Data Member */
	template<typename Class, typename T>
	class LuaStaticDataMember<Class, const T> : public BaseLuaStaticDataMember<Class>
	{
	public:
		typedef const T*	DataMember;

		LuaStaticDataMember(const char* name, DataMember member, bool bReadOnly);
		virtual ~LuaStaticDataMember();

		virtual void	setValue(Lua* lpLua, int idx);
		virtual void	getValue(Lua* lpLua);

	private:

		DataMember		m_Member;

		LuaStaticDataMember(const LuaStaticDataMember& refLuaStaticDataMember);
		LuaStaticDataMember& operator=(const LuaStaticDataMember& refLuaStaticDataMember);
	};

}

#include "LuaStaticDataMember.inl"
#endif